home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / dviware / xdvi-dos / src / fontsub.c < prev    next >
C/C++ Source or Header  |  1992-10-21  |  1KB  |  63 lines

  1. /* ------------------------------ For MsDos -------------------------------*/
  2.  
  3. /*
  4.  
  5.     These routines are written for opening and searching the font
  6.     substitute file pointed to by the environmental variable "TEXFONTSUB"
  7.  
  8.     10/OCT/1992   Eric Ho   9041477@SSCVAX.MCMASTER.CA
  9.  
  10. */
  11.  
  12. #ifdef FONTSUB
  13.  
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16.  
  17. FILE *openfontsubfile (void);
  18. char *subfont (FILE *,char *);
  19.  
  20.  
  21. char *subfont (fptr,font)
  22. FILE *fptr;
  23. char *font;
  24. {
  25.   char  ofont[30],      /* original font        */
  26.         sfont[30];      /* font to be substitute */
  27.  
  28.   rewind (fptr);
  29.   while (!feof (fptr)) {
  30.     fscanf (fptr,"%s -> %s",ofont,sfont);
  31.     if (strcmp (ofont,font) == 0) {
  32. /*      fprintf (stderr,"Replacing %s with %s\n",font,sfont); */
  33.       return (sfont);
  34.     }
  35.   }
  36.   return (NULL);
  37. }
  38.  
  39.  
  40.  
  41. FILE *openfontsubfile (void)
  42. {
  43.   FILE *fptr;
  44.   char fontsfname[64],
  45.        *sptr;             /* font substitue file name */
  46.  
  47.   if ((sptr = (char *) getenv ("TEXFONTSUB")) != (char *) NULL) {
  48.     (void) strcpy (fontsfname,sptr);
  49.     if ((fptr = fopen (fontsfname,"r")) != (FILE *) NULL) {
  50.       return ((FILE *) fptr);
  51.     } else {
  52.       fprintf (stderr,"\n\nFont substitute file not found!\n");
  53.       fprintf (stderr,"Check environmental variable TEXFONTSUB!\n\n");
  54.       return ((FILE *) NULL);
  55.     }
  56.   } else {
  57.     fprintf (stderr,"\n\nCheck environmental variable TEXFONTSUB!\n\n");
  58.     return ((FILE *) NULL);
  59.   }
  60. }
  61.  
  62. #endif
  63.